package fun.codedesign.yinxue.code.php2java.model;

import fun.codedesign.yinxue.code.php2java.service.Php2JavaService;
import org.yinxue.swing.core.domain.FileObject;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

public class PhpProject {
    public String path = "D:\\phpstudy_pro\\WWW\\api-portal-activity-center";
    String targetPath = "C:\\Users\\zengjian\\Desktop\\php-java\\activity-center\\src\\main\\java";

    protected Set<FileObject> phpFileList = new HashSet<>();
    private Php2JavaService php2JavaService = new Php2JavaService();

    public String addPhpFile(FileObject file) {
        phpFileList.add(file);
        return null;
    }

    public Integer fileSize() {
        return phpFileList.size();
    }

    public Integer generateJavaFile() {
        int count = 0;
        for (FileObject fileObject : phpFileList) {
            Php2JavaContext context  = php2JavaService.readFileAndCreateFile(fileObject);
            boolean flag = context.createJavaFile(targetPath);
            if (flag){
                count++;
            }
        }
        return count;
    }
}
